const { Sequelize } = require("sequelize");

const sequelize = new Sequelize("qa_data", "root", "123456", {
  host: "localhost",
  port: "3306",
  dialect:
    "mysql" /* one of 'mysql' | 'postgres' | 'sqlite' | 'mariadb' | 'mssql' | 'db2' | 'snowflake' | 'oracle' */,
});

const mysql = {
  init: async () => {
    try {
      await sequelize.authenticate();
      console.log("Connection has been established successfully.");
    } catch (error) {
      console.error("Unable to connect to the database:", error);
    }
  },
  destroy: () => {
    sequelize.close();
  },
};

module.exports = mysql;
